package com.lzxuni.controller;

import java.text.SimpleDateFormat;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONArray;
import com.lzxuni.po.RhDataCustom;
import com.lzxuni.service.RhDataService;
import com.lzxuni.utils.MethodUtil;

@Controller
public class SendDataController {
	@Autowired
	private RhDataService rhDataService;
	
	@ResponseBody
	@RequestMapping("/rhdata.html")
	public Object rhSendData(String date) throws Exception{
		SimpleDateFormat sdf=new SimpleDateFormat("yyyyMMddHHmmss");
		String createTime=MethodUtil.formatDate(0,sdf.parse(date));
		List<RhDataCustom> rhDataCustoms=rhDataService.findRhDataByTime(createTime);
		if(rhDataCustoms!=null&&rhDataCustoms.size()>0){
			JSONArray jArray=new JSONArray();
			jArray=(JSONArray) JSONArray.toJSON(rhDataCustoms);
			System.out.println(jArray);
			return jArray;
		}else{
			System.out.println("空空空空空空空空空空空空");
			return "";
		}
	}
}
